package com.thinktank.controller;

import static com.thinktank.util.DbUtil.close;
import static com.thinktank.util.DbUtil.getConnection;

import java.io.*;
import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

import com.thinktank.dao.*;
import com.thinktank.vo.*;

public class AlbumDeleteController implements Controller {

	@Override
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {
		// TODO Auto-generated method stub
		String path = request.getParameter("path");
		String bNo = request.getParameter("bNo");
		
		Connection con = getConnection();				
		AlbumDao dao = new AlbumDao(con);

		int result = dao.delete(path);
		if(result != 0){
			// 절대경로 받고, path랑 합쳐서 파일 삭제
		}
		close(con);
		
		request.setAttribute("board", bNo);
		
		if(result == 0) {
			return "error.jsp";
		}
		
		return "redirect:../board/boardDetail.do";
	}

}
